package org.example;

import com.team.sorting.SelectionSort;
import com.team.sorting.BubbleSort;
import com.team.sorting.InsertionSort;
import com.team.sorting.QuickSort;
import com.team.sorting.MergeSort;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int[] arr = {5, 2, 9, 1, 5, 6};
        System.out.println("原始数组：");
        printArray(arr);

        System.out.println("\n请选择排序算法:");
        System.out.println("1 - 选择排序：谭紫佳");
        System.out.println("2 - 冒泡排序：付酉");
        System.out.println("3 - 插入排序：夏天宇");
        System.out.println("4 - 快速排序：向凯杰");
        System.out.println("5 - 归并排序：聂嘉");
        System.out.print("请输入选项 (1-5): ");

        int choice = scanner.nextInt();
        int[] sortedArr = arr.clone();

        switch (choice) {
            case 1:
                new SelectionSort().sort(sortedArr);
                break;
            case 2:
                new BubbleSort().sort(sortedArr);
                break;
            case 3:
                new InsertionSort().sort(sortedArr);
                break;
            case 4:
                new QuickSort().sort(sortedArr, 0, sortedArr.length - 1);
                break;
            case 5:
                new MergeSort().sort(sortedArr, 0, sortedArr.length - 1);
                break;
            default:
                System.out.println("无效输入");
                return;
        }

        System.out.println("排序后的结果：");
        printArray(sortedArr);
        scanner.close();
    }

    private static void printArray(int[] arr) {
        for (int num : arr) {
            System.out.print(num + " ");
        }
        System.out.println();
    }
}
